package com.css.fxfzdzzh.config.thread;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.*;

/**
 * @author Dbj
 * @date 2023年03月31日  10:03
 * 线程池配置类
 */
@Configuration
public class ThreadPoolConfig {
    @Bean("myTaskExecutor")
    public Executor myTaskExecutor() {
        ThreadPoolExecutor executor = new
                ThreadPoolExecutor(5,
                Runtime.getRuntime().availableProcessors() * 3,
                5,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(1000), Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy());
        return executor;
    }
}
